// 保存token到本地存储
export const setToken = (token) => {
  localStorage.setItem('token', token)
}

// 从本地存储获取token
export const getToken = () => {
  return localStorage.getItem('token')
}

// 从本地存储移除token
export const removeToken = () => {
  localStorage.removeItem('token')
}

// 保存用户信息到本地存储
export const setUserInfo = (userInfo) => {
  localStorage.setItem('userInfo', JSON.stringify(userInfo))
}

// 从本地存储获取用户信息
export const getUserInfo = () => {
  const userInfo = localStorage.getItem('userInfo')
  return userInfo ? JSON.parse(userInfo) : null
}

// 从本地存储移除用户信息
export const removeUserInfo = () => {
  localStorage.removeItem('userInfo')
}

// 清除所有认证信息
export const clearAuth = () => {
  removeToken()
  removeUserInfo()
}
